#include<iostream>
#include<map>
#include<algorithm>
using namespace std;
map<string, int>mp;
const int N = 110;
int a[N], b[N];
int n, m;
int cmp(int a, int b)
{
	return a > b;
}
int main()
{
	cin >> n >> m;
	for (int i = 1; i <= n; i++)cin >> a[i];
	int ma = 0;
	while (m--) {
		string s;
		cin >> s;
		mp[s]++;
	}
	int cnt = 0;
	for (auto item : mp) {
		b[++cnt] = item.second;
	}
	sort(a + 1, a + n + 1,cmp);
	sort(b + 1, b + cnt + 1, cmp);
	int ans1 = 0, ans2 = 0;
	for (int i = 1; i <= cnt; i++) {
		ans1 += a[n--] * b[i];
		ans2 += a[i] * b[i];
	}
	cout << ans1 << " " << ans2 << endl;
	return 0;
}